<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>快递物流系统</title>
<link rel="stylesheet" href="lib/layui/css/layui.css" media="all" />

<script type="text/javascript" src="lib/layui/layui.js"></script>
<style>
.layui-input {
	width: 300px;
	display: inline;
	position: relative;
	top: 1px;
}
</style>
</head>

<body
	style="background-color: white; padding: 40px 20px 20px 20px; overflow-y: scroll;">
	<input type="text"  placeholder="姓名" name="taker_name"  class="layui-input">
	<button class="layui-btn" onclick="searchs()">
		<i class="layui-icon"></i>搜索
	</button>

	<table id="demo"></table>

	<script type="text/html" id="barDemo">  
  	 <a onclick="edit()" class="layui-btn layui-btn-xs">选择</a>
  </script>
	<script type="text/javascript">
  	//var network = JSON.parse($.cookie('network'));
 
    layui.use(['table','layer','jquery'], function(){
	  table = layui.table;
	  $=layui.jquery;
	  layer = layui.layer;
	  //第一个实例
	  table.render({
	    elem: '#demo'	    
	    ,url:  'api/emp?op=list'//数据接口
	    ,id: 'takerTable'
	    ,page: true //开启分页
	    ,cols: [[ //表头
	    		{
				title: "全选",
				width: 30,
				type: "checkbox",
				fixed: 'left'}
	            ,{title: '序号',type:'numbers'}
	  	        ,{field: 'take_name', title: '员工姓名'}
	  	        ,{field: 'taker_id', title: '员工编号'}
	  	        ,{title: '操作', toolbar: '#barDemo', align : 'center'}
	    ]]
	  });	 
	  
	  
	  function searchs(){	 	  
	    	table.reload('table', {
				 
				  where: {
					  name : $("[name='taker_name']").val(),//查询的数据条件
				  }
				  ,page: {
	  		    curr: 1 //重新从第 1 页开始
			  }
			  });
		}

	    function edit(){
	    	
	    	 var checkStatus = table.checkStatus('takerTable');
	         var data = checkStatus.data;
	         console.log(data.take_name);
	         if(data.length > 0) {
	        	 parent.$("[name='take_name']").val(data.take_name);
		         parent.$("[name='taker_id']").val(data.taker_id);
	             }
		     
		
			  parent.layer.closeAll(); 
	    }
	  
	});
    
    
   
  </script>
</body>
</html>